package icu.sehnen.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import icu.sehnen.mapper.NewsMapper;
import icu.sehnen.model.NewsModel;
import icu.sehnen.model.ProductModel;
import icu.sehnen.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NewsServiceImpl implements NewsService {
    @Autowired
    NewsMapper newsMapper;
    @Override
    public PageInfo<NewsModel> findAll(Integer pageNum, Integer pageSize, String query) {
        PageHelper.startPage(pageNum,pageSize);
        List<NewsModel> newsModelList=newsMapper.findAll(query);
        PageInfo<NewsModel> pageInfo=new PageInfo(newsModelList);
        return pageInfo;
    }

    @Override
    public void add(NewsModel newsModel) {
        newsMapper.add(newsModel);
    }

    @Override
    public void update(NewsModel newsModel) {
        newsMapper.update(newsModel);
    }

    @Override
    public NewsModel find(Long id) {
        return  newsMapper.find(id);
    }

    @Override
    public void  delete(Long id) {
        newsMapper.delete(id);
    }
}
